﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace MetaProperties.Core
{
    using System.ComponentModel;

    using Framework;

    /// <summary>
    /// An untyped observable value.
    /// </summary>
    public abstract class UntypedObservable : IObservable
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="UntypedObservable"/> class.
        /// </summary>
        protected UntypedObservable()
        {
        }

        /// <summary>
        /// Occurs when a property value changes.
        /// </summary>
        public abstract event PropertyChangedEventHandler PropertyChanged;

        /// <summary>
        /// Occurs when a property value is changing.
        /// </summary>
        public abstract event PropertyChangingEventHandler PropertyChanging;

        /// <summary>
        /// Occurs when a property value changes.
        /// </summary>
        public abstract event ValueChangedEventHandler UntypedValueChanged;

        /// <summary>
        /// Occurs when a property value is set.
        /// </summary>
        public abstract event ValueChangedEventHandler UntypedValueSet;

        /// <summary>
        /// Gets the untyped meta property.
        /// </summary>
        /// <value>The untyped meta property.</value>
        public IMetaProperty UntypedMetaProperty
        {
            get { return this.GetMetaProperty(); }
        }

        /// <summary>
        /// Gets the untyped value.
        /// </summary>
        /// <value>The untyped value.</value>
        public object UntypedValue
        {
            get 
            {
                return this.GetValue(); 
            }
        }

        /// <summary>
        /// Gets the value.
        /// </summary>
        /// <returns>The contained value.</returns>
        protected abstract object GetValue();
        
        /// <summary>
        /// Gets the MetaProperty.
        /// </summary>
        /// <returns>The MetaProperty.</returns>
        protected abstract IMetaProperty GetMetaProperty();
    }
}
